using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using SqlSugar;

namespace FytSoa.Domain.Erp;

/// <summary>
/// erp_流程使用
/// </summary>
[SugarTable("erp_flow_use")]
public class ErpFlowUse:Entity
{
    /// <summary>
    /// 流程编号
    /// </summary>
    [Required]
    public long FlowId { get; set; }

    /// <summary>
    /// 节点包括自定义
    /// </summary>
    [Required]
    [SugarColumn(IsJson = true)]
    public List<ErpFlowUseNodes> Nodes { get; set; } = new();

    /// <summary>
    /// 表单内容
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<FormModel> Form { get; set; } = new();

    /// <summary>
    /// 使用者编号
    /// </summary>
    [Required]
    public long UseId { get; set; }

    /// <summary>
    /// 流程类型
    /// </summary>
    [Required]
    public FlowTypeEnum Type { get; set; } = 0;

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public FlowAuditEnum Status { get; set; } = FlowAuditEnum.Await;

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    public class ErpFlowUseNodes
    {
        /// <summary>
        /// 编号 0=发起人
        /// </summary>
        public int Number { get; set; } = 1;
        
        /// <summary>
        /// 审批人
        /// </summary>
        public long EmployeeId { get; set; } = 0;

        /// <summary>
        /// 状态
        /// </summary>
        public FlowAuditEnum Status { get; set; } = 0;
    }
    
    public class FormModel
    {
        public string Label { get; set; }

        public string Name { get; set; }

        public string Value { get; set; }
    }
}